package com.huatai.auth.service;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.huatai.user.entity.LoginLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * @program: ht-system
 * @description: ces
 * @author: songxiude
 * @create: 2023-11-07 09:32
 **/
@Service
public class ThreadPoolService {


	@Autowired
	private LoginLogService loginLogService;

	@Async("threadPoolAuthExecutor")
	public void saveLog(HtUserDetails htUserDetails){
		//记录用户登录信息
		LoginLog loginLog = new LoginLog();
		loginLog.setId(IdWorker.getId());
		loginLog.setLoginId(htUserDetails.getId());
		loginLog.setLoginUser(htUserDetails.getUsername());
		loginLog.setLoginTime(LocalDateTime.now());
		loginLogService.save(loginLog);
	}
}
